package com.youbug.mall.coupon_sms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.coupon_sms.entity.SmsMemberPrice;
import com.youbug.mall.coupon_sms.service.ISmsMemberPriceService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品会员价格 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-04-24
 */
@RestController
@RequestMapping("/smsMemberPrice")
public class SmsMemberPriceController {
@Autowired
private ISmsMemberPriceService smsMemberPriceService;

    @PostMapping("/getSmsMemberPricePage")
    public R<IPage<SmsMemberPrice>> getSmsMemberPricePage(@RequestBody QueryVo<SmsMemberPrice> queryVo){

        IPage<SmsMemberPrice> smsMemberPrices = smsMemberPriceService.getSmsMemberPricePage(queryVo);

        return R.ok(smsMemberPrices);
    }

    @GetMapping("/getSmsMemberPriceById/{id}")
    public R<SmsMemberPrice> getSmsMemberPriceById(@PathVariable Integer id){

        SmsMemberPrice smsMemberPrice = smsMemberPriceService.getById(id);

        return R.ok(smsMemberPrice);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody SmsMemberPrice smsMemberPrice){

        boolean save = smsMemberPriceService.save(smsMemberPrice);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody SmsMemberPrice smsMemberPrice){

        boolean update = smsMemberPriceService.updateById(smsMemberPrice);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = smsMemberPriceService.removeById(id);

        return  R.ok(remove);
    }
}

